package com.example.hw_demo.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.hw_demo.entity.HwFacilityToilet;
import com.example.hw_demo.service.HwFacilityToiletService;
import com.example.hw_demo.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/hw_ftc")
public class HwFacilityToiletController {
    @Autowired
   HwFacilityToiletService hwFacilityToiletService;
    @GetMapping("/selectPage")
    public Result selectPage(HwFacilityToilet hwFacilityToilet){
        return hwFacilityToiletService.selectpage(hwFacilityToilet);
    }
    //新增接口
    @PostMapping("/add")
    public Result add(@RequestBody HwFacilityToilet hwFacilityToilet){
        boolean bool = hwFacilityToiletService.save(hwFacilityToilet);
        return new Result(200,"新增成功",bool);
    }
    //修改
    @PostMapping("/update")
    public Result update(@RequestBody HwFacilityToilet hwFacilityToilet){
        //获取创建时间
        HwFacilityToilet hwFacilityToilet1 = hwFacilityToiletService.getById(hwFacilityToilet.getId());
        hwFacilityToilet.setCreateTime(hwFacilityToilet1.getCreateTime());
        boolean bool = hwFacilityToiletService.updateById(hwFacilityToilet);
        return new Result(200,"修改成功",bool);
    }
    //删除
    @DeleteMapping("/deleteHw")
    public Result deleteHw(@RequestParam int id){
        boolean bool = hwFacilityToiletService.removeById(id);
        return new Result(200,"删除成功",bool);
    }
}
